<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="shortcut icon" th:href="@{/pages/logo-1.ico}" href="../static/pages/logo-1.ico"/>
    <link rel="shortcut icon" th:href="@{/pages/logo-1.ico}" href="../static/pages/logo-1.ico"/>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" href="../static/layui/css/layui.css">
    <link rel="stylesheet" th:href="@{/layui/css/admin.css}" href="../static/layui/css/admin.css">
    <link rel="stylesheet" th:href="@{/layui/css/log.css}" href="../static/layui/css/log.css">
</head>
<body>
<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
    <div class="layadmin-user-login-main">
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <h2><img class="layui-nav-img" th:src="@{/pages/logo-1.ico}" src="../static/pages/logo-1.ico">THREE进销存系统</h2>
            <a href="https://gitee.com/hu-wei-liang/demo_three">源码下载链接地址</a>
            <p>账号：admin  密码：123456</p>
        </div>
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
<!--            <form action="login" method="post" id="loginId" onclick="login()">-->
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-username"></label>
                <input type="text" name="username" id="username" lay-verify="required" placeholder="用户名" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password"></label>
                <input type="password" name="password" id="password" lay-verify="required" placeholder="密码" readonly onfocus="this.removeAttribute('readonly');" class="layui-input">
            </div>
            <div class="layui-form-item" style="margin-bottom: 20px">
                <input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
                <a href="#" class="layadmin-user-jump-change layadmin-link" style="margin-top: 7px;">忘记密码？</a>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit" id="userlogin">登入</button>
            </div>
<!--            <div class="layui-trans layui-form-item layadmin-user-login-other">-->
<!--                <label>社区账号登入</label>-->
<!--                <a href="javascript:;" onclick="ons();"><i class="layui-icon layui-icon-login-qq"></i></a>-->
<!--                <a href="javascript:;" onclick="ons();"><i class="layui-icon layui-icon-login-wechat"></i></a>-->
<!--                <a href="javascript:;" id="ons" onclick="ons();"><i class="layui-icon layui-icon-login-weibo"></i></a>-->

<!--                <a href="#"  class="layadmin-user-jump-change layadmin-link">注册账号</a>-->
<!--            </div>-->
            <input type="hidden" name="redistime" id="redistime" th:value="${redistime}"/><!--删除弹窗-->
<!--            </form>-->
        </div>
    </div>
</div>

<script src="../static/layui/layui.js" th:src="@{/layui/layui.js}" type="text/javascript"></script>
<script src="../static/js/vue.min.js" th:src="@{/js/vue.min.js}" type="text/javascript"></script>
<script src="../static/js/jquery-3.6.3.min.js" th:src="@{/js/jquery-3.6.3.min.js}" type="text/javascript"></script>
<script th:inline="javascript">
    //Javascript代码区域
    layui.use(['layer','element','form','jquery'],function (){
        let layer = layui.layer;
        let form = layui.form;
        let element = layui.element;
        let $ = layui.jquery;

        $("#userlogin").click(function () {
            let username = $('#username').val()
            let password = $('#password').val()
            let redistime = $('#redistime').val();
            $.ajax({
                url:"/login/login",
                data:{
                    username:username,
                    password:password
                },
                type:"post",
                dataType :"json",
                cache : false,
                async : false,//设置同步（ajax请求此处需求为跳转而不是局部页面刷新）
                success:function (data1){
                    let a = data1;
                    if (a==1000||a==1001) {
                        window.location.href = "/login/index";
                    }else if(a>=0){
                        layer.open({
                            title: '登录次数已达上限!'
                            ,content: '请在'+a+'秒后重试!'
                        });
                    }else {
                        a=a+10,
                        layer.open({
                            title: '用户名或密码错误!'
                            ,content: '剩余'+a+'次机会!'
                        });
                    }
                }
            })
        });
    });
</script>
</body>
</html>
